package com.solr.sboot.solr.controller;

import com.solr.sboot.solr.po.DocumentPo;
import com.solr.sboot.solr.service.DocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @描述:
 * @类名:
 * @作者: yangshuang
 * @创建时间: 2017/8/21 14:30
 * @版本: v1.0
 */
@RestController
public class YtController {
    @Autowired
    private DocumentService documentService;

    @RequestMapping(value = "test")
    public void Test(){
      //  DocumentPo byId = documentService.findById("0003");
      //  System.out.println(byId);
    }

    @GetMapping(value ="/searchByName" )
    public void searchByName(String searchName, @PageableDefault(page = 0, size = 2) Pageable pageable){
    List<DocumentPo> documentPos= documentService.findByCustomQuery(searchName,pageable);
    }

//    @RequestMapping(value ="/saveDocument" )
    @GetMapping(value ="/saveDocument" )
    public void saveDocument(){
        DocumentPo documentPo = new DocumentPo();
        documentPo.setId("0006");
        documentPo.setTitle("测试题目12345");
        documentService.addDocument(documentPo);
    }


}
